//
//  TransitionViewController.m
//  QuickCare
//
//  Created by 唐润欣 on 16/7/11.
//  Copyright © 2016年 lidabiao. All rights reserved.
//

#import "TransitionViewController.h"
#import "WebViewController.h"
#import "AppDelegate.h"
#import "KyImage.h"
#import "DrawerManager.h"
#import "NavigationController.h"

#define count 5
@interface TransitionViewController () <imageProtocol>

@property (nonatomic, strong)KyImage *pic;
@property (nonatomic, assign)NSInteger index;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@end

@implementation TransitionViewController

-(void)viewDidAppear:(BOOL)animated{
    
    [super viewDidAppear:animated];
    //关掉侧滑
    [kDrawerManager disableLeftDrawer];
}

-(void)viewDidDisappear:(BOOL)animated
{
    kDrawerManager.drawerController.leftDrawerViewController = kDrawerManager.leftVC;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGFloat w = self.scrollView.bounds.size.width;
    CGFloat h = self.scrollView.bounds.size.height;
    
    for (int i = 0; i<count; i++) {
        
        KyImage *pic = [[KyImage alloc]init];
        NSString *imageName = [NSString stringWithFormat:@"img%d",i];
        pic.image = [UIImage imageNamed:imageName];
        
        pic.frame = CGRectMake(i * w, 0, w, h);
        [self.scrollView addSubview:pic];
        
        pic.index = i;
        pic.mid = self;
    }
    
    self.scrollView.contentSize = CGSizeMake(count * w, h);
    
    self.pic.userInteractionEnabled = YES;
}

- (void)skipController:(NSString *)title andwith:(NSString *)urlString{
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Discover" bundle:nil];
    WebViewController *webController = [sb instantiateViewControllerWithIdentifier:@"WebViewController"];
    webController.url = urlString;
    
    NavigationController *nav = [[NavigationController alloc] initWithRootViewController:webController];
    
    [self presentViewController:nav animated:YES completion:nil];
}

@end
